#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
void change(char* left, char* right)
{
	while (left < right)
	{
		int ret = 0;
		ret = *left;
		*left = *right;
		*right = ret;
		left++;
		right--;
	}
}
int main()
{
	char arr[100] = { 0 };
	gets(arr);
	int len = strlen(arr);
	change(arr, arr + len - 1);
	printf("%s", arr);
	char* start; char* end;
	start = arr;
	end = start;
	while (*start)
	{
		while (*end != ' ' && *end != '\0')
		{
			end++;
		}
		change(start, end - 1);
		if (*end != '\0')
		{
			end++;
		}
		start = end;
	}
	printf("\n%s", arr);

	return 0;
}
